<?php
session_start();
include_once "../apps/ManagerIUDS.php";
$managerIUDS = new ManagerIUDS();

$userName = $_POST["user_name"];
$password= $_POST["password"];
$name = $_POST["name"];
$surName = $_POST["sur_name"];
$email = $_POST["e_mail"];

$mode = $_GET["mode"];
if($mode == "" || $mode == null){
	$mode = $_POST["mode"];
}

if($mode == "insert"){
	$arrData["user_name"] ="".$userName."";
	$arrData["password"] ="".$password."";
	$arrData["name"] ="".$name."";
	$arrData["sur_name"] = "".$surName."";
	$arrData["e_mail"] ="".$email."";
	$arrData["user_type"] ="G";
	$managerIUDS->inserData($arrData, "user");
	//header("Window-target: _base");
	//header("Location:../index.php");
	echo("<script language=\"javascript\">"); 
	echo("top.location.href = \"../index.php\";"); 
	echo("</script>");  
}else if($mode="listUserName"){
	$userDara = $managerIUDS->queryData("user_name", "user", " WHERE user_name = '".$_GET["userName"]."'", "1", "");
	if(sizeof($userDara) >=1 ){
		$result = array("result"=>"Y");//found Data
	}elseif(sizeof($userDara) <=0 ){
		$result = array("result"=>"N");//not found Data
	}

	echo json_encode($result);
}
?>